/*
 * @Description:
 * @Author: YaoXiaotTian
 * @Date: 2021-04-29 20:51:49
 * @LastEditors: YaoXiaoTian
 * @LastEditTime: 2021-05-28 12:00:04
 */
//token
//引入token
var jwt = require("jsonwebtoken");
let secret = "yaoxiaotian";

// 生成token
exports.generateToken = function (e) {
  let payload = { id: e, time: new Date() };
  let token = jwt.sign(payload, secret, {
    // 授权时效24小时
    expiresIn: 60 * 60 * 240000000,
  });
  return token;
};

// 解码token
exports.verifyToken = function (e) {
  let payload = jwt.verify(e, secret);
  console.log(payload);
  return payload;
};
